package com.ruoyi.cbs.contract.service.impl;

import java.util.List;

import com.ruoyi.cbs.contract.domain.Contractor;
import com.ruoyi.cbs.contract.mapper.ContractorMapper;
import com.ruoyi.cbs.contract.service.IContractorService;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.uuid.IdFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 承包商信息Service业务层处理
 * 
 * @author ruoyi
 * @date 2025-10-31
 */
@Service
public class ContractorServiceImpl implements IContractorService
{
    @Autowired
    private ContractorMapper contractorMapper;

    /**
     * 查询承包商信息
     * 
     * @param id 承包商信息主键
     * @return 承包商信息
     */
    @Override
    public Contractor selectContractorById(Long id)
    {
        return contractorMapper.selectContractorById(id);
    }

    /**
     * 查询承包商信息列表
     * 
     * @param contractor 承包商信息
     * @return 承包商信息
     */
    @Override
    public List<Contractor> selectContractorList(Contractor contractor)
    {
        return contractorMapper.selectContractorList(contractor);
    }

    /**
     * 新增承包商信息
     * 
     * @param contractor 承包商信息
     * @return 结果
     */
    @Override
    public int insertContractor(Contractor contractor)
    {
        contractor.setCreateTime(DateUtils.getNowDate());
        contractor.setId(IdFactory.newLongId());
        contractor.setCreateBy("admin");
        return contractorMapper.insertContractor(contractor);
    }

    /**
     * 修改承包商信息
     * 
     * @param contractor 承包商信息
     * @return 结果
     */
    @Override
    public int updateContractor(Contractor contractor)
    {
        contractor.setUpdateTime(DateUtils.getNowDate());
        contractor.setUpdateBy(SecurityUtils.getUsername());
        return contractorMapper.updateContractor(contractor);
    }

    /**
     * 批量删除承包商信息
     * 
     * @param ids 需要删除的承包商信息主键
     * @return 结果
     */
    @Override
    public int deleteContractorByIds(Long[] ids)
    {
        return contractorMapper.deleteContractorByIds(ids);
    }

    /**
     * 删除承包商信息信息
     * 
     * @param id 承包商信息主键
     * @return 结果
     */
    @Override
    public int deleteContractorById(Long id)
    {
        return contractorMapper.deleteContractorById(id);
    }
}
